package com.cat.model.dao.common.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cat.model.common.model.common.PlmCityVO;
import com.cat.model.common.model.common.PlmCountryVO;
import com.cat.model.common.model.common.PlmProvinceVO;
import com.cat.model.dao.common.BasDAO;
import com.cat.model.dao.common.PlmCommDAO;
import com.cat.model.web.bean.AcntWithdrawBean;
import com.cat.model.web.bean.InfoSearchBean;
import com.cat.model.web.bean.ModelInfoBean;
import com.cat.model.web.bean.ModelInfoSearchBean;
import com.cat.model.web.bean.ReservationBean;
import com.cat.model.web.bean.UserAuthInfoBean;

public class PlmCommDAOImpl extends BasDAO implements PlmCommDAO {	
	
	@Override
	public List<?> search(String statementId, Map<String, Object> condition,
			Integer start, Integer num) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.putAll(condition);
		params.put("start", start);
		params.put("num", num);
		
		return this.selectList(statementId, params);
	}

	@Override
	public long searchSize(String statementId, Map<String, Object> condition) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.putAll(condition);
		
		Long result = (Long)this.selectOne(statementId, params);
		return result != null ? result : 0;
	}

	@Override
	public List<?> query(String statementId, Map<String, Object> condition) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.putAll(condition);
		
		return this.selectList(statementId, params);
	}
	
	/**
	 * 根据条件查询单笔记录
	 * */
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> queryOne(String statementId, Map<String, Object> condition){
		Map<String, Object> params = new HashMap<String, Object>();
		params.putAll(condition);
		
		return (Map<String, Object>) this.selectOne(statementId, params);
	}
	
	@Override
	public ReservationBean getReservationDetail(Long id) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		
		return (ReservationBean) this.selectOne("manager.searchReservation", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ReservationBean> getReservationShortlist(Long reservationId) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("reservationId", reservationId);
		
		return (List<ReservationBean>) this.selectList("manager.searchReservationShortlist", params);
	}

	@Override
	public UserAuthInfoBean getUserAuthInfo(Long id) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		
		return (UserAuthInfoBean) this.selectOne("manager.searchUserAuthInfo", params);
	}
	
	@Override
	public AcntWithdrawBean getAcntWithdraw(Long id) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		
		return (AcntWithdrawBean) this.selectOne("manager.searchAcntWithdraw", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PlmCityVO> getAllPlmCity() {
		Map<String, Object> params = new HashMap<String, Object>();
		
		return (List<PlmCityVO>) this.selectList("manager.getAllPlmCity", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PlmCountryVO> getPlmCountry() {
		Map<String, Object> params = new HashMap<String, Object>();
		
		return (List<PlmCountryVO>) this.selectList("manager.getPlmCountry", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PlmProvinceVO> getPlmProvince(String countryCode) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("countryCode", countryCode);
		
		return (List<PlmProvinceVO>) this.selectList("manager.getPlmProvince", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PlmCityVO> getPlmCity(String provinceCode) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("provinceCode", provinceCode);
		
		return (List<PlmCityVO>) this.selectList("manager.getPlmCity", params);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<ModelInfoBean> getModelInfo(ModelInfoSearchBean model) {
		Map<String, Object> params = new HashMap<String, Object>();
		if(model.getCityCode()!=null){
			params.put("cityCode", model.getCityCode());
		}
		if(model.getSex()!=null){
			params.put("sex", model.getSex());
		}
		if(model.getMinAge()!=null){
			params.put("minAge", model.getMinAge());
		}
		if(model.getMinHeight()!=null){
			params.put("minHeight", model.getMinHeight());
		}
		if(model.getMinWeight()!=null){
			params.put("minWeight", model.getMinWeight());
		}
		if(model.getMinShoeSize()!=null){
			params.put("minShoeSize", model.getMinShoeSize());
		}
		if(model.getMinBustSize()!=null){
			params.put("minBustSize", model.getMinBustSize());
		}
		if(model.getMinHiplineSize()!=null){
			params.put("minHiplineSize", model.getMinHiplineSize());
		}
		if(model.getMinWaistSize()!=null){
			params.put("minWaistSize", model.getMinWaistSize());
		}
		if(model.getMinCupSize()!=null){
			params.put("minCupSize", model.getMinCupSize());
		}
		if(model.getMaxAge()!=null){
			params.put("maxAge", model.getMaxAge());
		}
		if(model.getMaxHeight()!=null){
			params.put("maxHeight", model.getMaxHeight());
		}
		if(model.getMaxWeight()!=null){
			params.put("maxWeight", model.getMaxWeight());
		}
		if(model.getMaxShoeSize()!=null){
			params.put("maxShoeSize", model.getMaxShoeSize());
		}
		if(model.getMaxBustSize()!=null){
			params.put("maxBustSize", model.getMaxBustSize());
		}
		if(model.getMaxHiplineSize()!=null){
			params.put("maxHiplineSize", model.getMaxHiplineSize());
		}
		if(model.getMaxWaistSize()!=null){
			params.put("maxWaistSize", model.getMaxWaistSize());
		}
		if(model.getMaxCupSize()!=null){
			params.put("maxCupSize", model.getMaxCupSize());
		}
		if(model.getStyleCode()!=null){
			params.put("styleCode", model.getStyleCode());
			int styleCodeSize=model.getStyleCode().split(",").length;
			params.put("styleCodeSize", styleCodeSize);
		}
		if(model.getExperCode()!=null){
			params.put("experCode", model.getExperCode());
		}
		if(model.getHairColorCode()!=null){
			params.put("hairColorCode", model.getHairColorCode());
		}
		if(model.getRaceCode()!=null){
			params.put("raceCode", model.getRaceCode());
		}
		if(model.getEyeCode()!=null){
			params.put("eyeCode", model.getEyeCode());
		}
		if(model.getSkinColorCode()!=null){
			params.put("skinColorCode(", model.getSkinColorCode());
		}
		if(model.getMinArmLength()!=null){
			params.put("minArmLength", model.getMinArmLength());
		}
		if(model.getMinLegSize()!=null){
			params.put("minLegSize", model.getMinLegSize());
		}
		if(model.getMinUpArmSize()!=null){
			params.put("minUpArmSize", model.getMinUpArmSize());
		}
		if(model.getMinThighSize()!=null){
			params.put("minThighSize", model.getMinThighSize());
		}
		if(model.getMaxArmLength()!=null){
			params.put("maxArmLength", model.getMaxArmLength());
		}
		if(model.getMaxLegSize()!=null){
			params.put("maxLegSize", model.getMaxLegSize());
		}
		if(model.getMaxUpArmSize()!=null){
			params.put("maxUpArmSize", model.getMaxUpArmSize());
		}
		if(model.getMaxThighSize()!=null){
			params.put("maxThighSize", model.getMaxThighSize());
		}
		if(model.getMaxPrice()!=null){
			params.put("maxPrice", model.getMaxPrice());
		}
		if(model.getMinPrice()!=null){
			params.put("minPrice", model.getMinPrice());
		}
		if(model.getAgeGroup()!=null){
			params.put("ageGroup", model.getAgeGroup());
		}
		if(model.getMinNeckLength()!=null){
			params.put("minNeckLength", model.getMinNeckLength());
		}
		if(model.getMinNeckSize()!=null){
			params.put("minNeckSize", model.getMinNeckSize());
		}
		if(model.getMaxNeckLength()!=null){
			params.put("maxNeckLength", model.getMaxNeckLength());
		}
		if(model.getMaxNeckSize()!=null){
			params.put("maxNeckSize", model.getMaxNeckSize());
		}
		if(model.getMaxHeadSize()!=null){
			params.put("maxHeadSize", model.getMaxHeadSize());
		}
		if(model.getMinHeadSize()!=null){
			params.put("minHeadSize", model.getMinHeadSize());
		}
		if(model.getMaxCollarSize()!=null){
			params.put("maxCollarSize", model.getMaxCollarSize());
		}
		if(model.getMinCollarSize()!=null){
			params.put("minCollarSize", model.getMinCollarSize());
		}
		if(model.getMaxShoulderSize()!=null){
			params.put("maxShoulderSize", model.getMaxShoulderSize());
		}
		if(model.getMinShoulderSize()!=null){
			params.put("minShoulderSize", model.getMinShoulderSize());
		}
		if(model.getMaxAnnLength()!=null){
			params.put("maxAnnLength", model.getMaxAnnLength());
		}
		if(model.getMinAnnLength()!=null){
			params.put("minAnnLength", model.getMinAnnLength());
		}
		if(model.getMaxSleeveLength()!=null){
			params.put("maxSleeveLength", model.getMaxSleeveLength());
		}
		if(model.getMinSleeveLength()!=null){
			params.put("minSleeveLength", model.getMinSleeveLength());
		}
		if(model.getMaxCenterBack()!=null){
			params.put("maxCenterBack", model.getMaxCenterBack());
		}
		if(model.getMinCenterBack()!=null){
			params.put("minCenterBack", model.getMinCenterBack());
		}
		if(model.getMaxChestSize()!=null){
			params.put("maxChestSize", model.getMaxChestSize());
		}
		if(model.getMinChestSize()!=null){
			params.put("minChestSize", model.getMinChestSize());
		}
		if(model.getMaxUnderbustSize()!=null){
			params.put("maxUnderbustSize", model.getMaxUnderbustSize());
		}
		if(model.getMinUnderbustSize()!=null){
			params.put("minUnderbustSize", model.getMinUnderbustSize());
		}
		if(model.getMaxHighHipSize()!=null){
			params.put("maxHighHipSize", model.getMaxHighHipSize());
		}
		if(model.getMinHighHipSize()!=null){
			params.put("minHighHipSize", model.getMinHighHipSize());
		}
		if(model.getMaxMidHipSize()!=null){
			params.put("maxMidHipSize", model.getMaxMidHipSize());
		}
		if(model.getMinMidHipSize()!=null){
			params.put("minMidHipSize", model.getMinMidHipSize());
		}
		if(model.getMaxLowHipSize()!=null){
			params.put("maxLowHipSize", model.getMaxLowHipSize());
		}
		if(model.getMinLowHipSize()!=null){
			params.put("minLowHipSize", model.getMinLowHipSize());
		}
		if(model.getMaxWristSize()!=null){
			params.put("maxWristSize", model.getMaxWristSize());
		}
		if(model.getMinWristSize()!=null){
			params.put("minWristSize", model.getMinWristSize());
		}
		if(model.getMaxOutseamSize()!=null){
			params.put("maxOutseamSize", model.getMaxOutseamSize());
		}
		if(model.getMinOutseamSize()!=null){
			params.put("minOutseamSize", model.getMinOutseamSize());
		}
		if(model.getMaxInseamSize()!=null){
			params.put("maxInseamSize", model.getMaxInseamSize());
		}
		if(model.getMinInseamSize()!=null){
			params.put("minInseamSize", model.getMinInseamSize());
		}
		if(model.getMaxCalfSize()!=null){
			params.put("maxCalfSize", model.getMaxCalfSize());
		}
		if(model.getMinCalfSize()!=null){
			params.put("minCalfSize", model.getMinCalfSize());
		}
		if(model.getMaxAnkleSize()!=null){
			params.put("maxAnkleSize", model.getMaxAnkleSize());
		}
		if(model.getMinAnkleSize()!=null){
			params.put("minAnkleSize", model.getMinAnkleSize());
		}
		if(model.getSuitSizes()!=null){
			params.put("suitSizes", model.getSuitSizes());
		}
		if(model.getCompanyId()!=null){
			params.put("companyId", model.getCompanyId());
		}
		return (List<ModelInfoBean>) this.selectList("manager.getModelInfo", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<InfoSearchBean> getPhotographerList(ModelInfoSearchBean searchBean) {
		Map<String, Object> params = new HashMap<String, Object>();
		if(searchBean.getCityCode()!=null){
			params.put("cityCode", searchBean.getCityCode());
		}
		if(searchBean.getMaxPrice()!=null){
			params.put("maxPrice", searchBean.getMaxPrice());
		}
		if(searchBean.getMinPrice()!=null){
			params.put("minPrice", searchBean.getMinPrice());
		}
		if(searchBean.getStyleCode()!=null){
			params.put("styleCode", searchBean.getStyleCode());
		}
		
		return (List<InfoSearchBean>) this.selectList("manager.getPhotographerInfo", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<InfoSearchBean> getDressupList(ModelInfoSearchBean searchBean) {
		Map<String, Object> params = new HashMap<String, Object>();
		if(searchBean.getCityCode()!=null){
			params.put("cityCode", searchBean.getCityCode());
		}
		if(searchBean.getMaxPrice()!=null){
			params.put("maxPrice", searchBean.getMaxPrice());
		}
		if(searchBean.getMinPrice()!=null){
			params.put("minPrice", searchBean.getMinPrice());
		}
		if(searchBean.getStyleCode()!=null){
			params.put("styleCode", searchBean.getStyleCode());
		}
		
		return (List<InfoSearchBean>) this.selectList("manager.getDressupInfo", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<InfoSearchBean> getMakeupList(ModelInfoSearchBean searchBean) {
		Map<String, Object> params = new HashMap<String, Object>();
		if(searchBean.getCityCode()!=null){
			params.put("cityCode", searchBean.getCityCode());
		}
		if(searchBean.getMaxPrice()!=null){
			params.put("maxPrice", searchBean.getMaxPrice());
		}
		if(searchBean.getMinPrice()!=null){
			params.put("minPrice", searchBean.getMinPrice());
		}
		if(searchBean.getStyleCode()!=null){
			params.put("styleCode", searchBean.getStyleCode());
		}
		
		return (List<InfoSearchBean>) this.selectList("manager.getMakeupInfo", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<InfoSearchBean> getGraphicsList(ModelInfoSearchBean searchBean) {
		Map<String, Object> params = new HashMap<String, Object>();
		if(searchBean.getCityCode()!=null){
			params.put("cityCode", searchBean.getCityCode());
		}
		if(searchBean.getMaxPrice()!=null){
			params.put("maxPrice", searchBean.getMaxPrice());
		}
		if(searchBean.getMinPrice()!=null){
			params.put("minPrice", searchBean.getMinPrice());
		}
		if(searchBean.getStyleCode()!=null){
			params.put("styleCode", searchBean.getStyleCode());
		}
		
		return (List<InfoSearchBean>) this.selectList("manager.getGraphicsInfo", params);
	}
}
